//
//  HomePageRoute.swift
//  Pods
//
//  Created by eme on 2017/3/24.
//
//

import Foundation
import Alamofire
import ModelProtocol
import CryptoSwift
import NetWorkCore

/*
 owner:cy
 update:2017年01月17日17:43:56
 info: 首页界面 api

 */

public enum HomePageApi{
    ///获取首页数据
    case firstPage
    ///新首页数据
    case index
    ///获取七牛云uptoken
    case uptoken
    case getrecommendmore(page:Int,length:Int,id:String)
    /// 获取商品详情model 带sku信息的
    case glproductskus(pdid:String)
    ///显示首页搜索页面
    case seachIndex
    /*
     首页搜索界面
     
     keyword:
     required
     string美白面膜
     搜索关键字
     brid:	string
     品牌ID
     ptid:	string
     分类ID
     firistflag:
     required
     string1
     分类ID 第一次查询标志（1-是2-否）（第一次查询会返回品牌，类目，属性信息）
     pavstr:	string
     属性值，以，分隔
     oflag:	string
     排序标志（1-销量2-毛利3-价钱升序4-价钱降序） 非必填
     minamount:	bigdecimal
     金额区间开始 非必填
     maxamount:	bigdecimal
     金额区间结束
     moq:	int
     起批量
     page:
     required
     int
     起批量
     length:
     required
     int
     起批量
     */
    case seachproducts(keyword:String,brid:String,ptid:String,firistflag:String,pavstr:String,oflag:String,minamount:String,maxamount:String,moq:String,page:Int,length:Int,vid:String)
    //首页 默认关键字
    case defaultkeyword
    //    觅客商城秒杀活动数据
    case getistimebyone(id:String)
    
}
extension HomePageApi: TargetType {
    
    //设置请求路径
    public var path: String {
        switch self {
        case .firstPage:
            return "/firstPage/index.json"
        case .index:
            return "/appConfig/index.json"
        case .uptoken:
            return "/uptoken.json"
        case .getrecommendmore:
            return "/appConfig/getProductByResourceid.json"
        case .glproductskus:
            return "/glProduct/skus.json"
        case .seachIndex:
            return "/seProduct/seachIndex.json"
        case .seachproducts:
            return "/seProduct/seachproducts.json"
        case .defaultkeyword:
            return "/firstPage/defaultkeyword.json"
        case .getistimebyone:
            return "/appConfig/getProductByRecommend.json"
        }
    }
    
    //设置请求方式 get post等
    public var method: HTTPMethod {
        switch self {
        default :
            return .post
            
        }
    }
    /// 设置请求参数
    public var parameters: Parameters? {
        switch self {
        case let .getrecommendmore(page, length,id):
            return ["page": page, "length": length,"id":id]
        case let .glproductskus(pdid):
            return ["pdid":pdid]
        case let .seachproducts(keyword,brid,ptid,firistflag,pavstr,oflag,minamount,maxamount,moq,page,length,vid):
            return ["keyword":keyword,"brid":brid,"ptid":ptid,"firistflag":firistflag,"pavstr":pavstr,"oflag":oflag,"minamount":minamount,"maxamount":maxamount,"moq":moq,"page": page, "length": length,"vid":vid]
        case let .getistimebyone(id):
            return ["id":id]
        default :
            return nil
        }
    }
    
}
